package com.contactmgr.activity;

import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

import com.contactmgr.R;
import com.contactmgr.listadapter.CallListAdapter;
import com.contactmgr.listadapter.SeparatedListAdapter;
import com.contactmgr.logObjects.CallDataLog;
import com.contactmgr.utils.ReadDataAppContext;

public class CallLogActivity extends ListActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		/** separated list adapter for call log **/
		List<CallDataLog> nameResolvedMissedCallData = ((ReadDataAppContext) getApplicationContext()).getNameResolvedMissedCallData();
		List<CallDataLog> nameResolvedIncomingCallData = ((ReadDataAppContext) getApplicationContext()).getNameResolvedIncomingCallData();
		List<CallDataLog> nameResolvedOutgoingCallData = ((ReadDataAppContext) getApplicationContext()).getNameResolvedOutGoingCallData();
		SeparatedListAdapter callLogAllAdp = new SeparatedListAdapter(this);
		ArrayAdapter<CallDataLog> missedCallAdp = new CallListAdapter(this, R.layout.list_call, nameResolvedMissedCallData);
		ArrayAdapter<CallDataLog> incomingCallAdp = new CallListAdapter(this, R.layout.list_call, nameResolvedIncomingCallData);
		ArrayAdapter<CallDataLog> outgoingCallAdp = new CallListAdapter(this, R.layout.list_call, nameResolvedOutgoingCallData);
		callLogAllAdp.addSection("Missed Calls", missedCallAdp);
		callLogAllAdp.addSection("Incoming Calls", incomingCallAdp);
		callLogAllAdp.addSection("Outgoing Calls", outgoingCallAdp);
		this.setListAdapter(callLogAllAdp);
	}

}
